package com.lovo.test.ATM;

import com.lovo.test.Util.Util;

import javax.swing.*;
import java.awt.*;

//ATM界面
public class ATM extends JFrame  {
    //以下是图片封装
    private Image bjImg= Util.getImage("/ATMimages/background.jpg");//背景图



   //以下是布局所有界面
    private CardLayout cardLayout = new CardLayout();//卡片布局对象
    private MenuPanel menuPanel = new MenuPanel(this);//产生菜单对象
    private LoginPanel loginPanel = new LoginPanel(this);//产生登录对象
    private TakePanel takePanel= new TakePanel(this);//产生取款对象
    private CheckPanel checkPanel = new CheckPanel(this);//产生查询对象
    private StorePanel storePanel = new StorePanel(this);//产生存款对象


    public ATM(){
        //背景图片引入
        this.setContentPane(new JPanel(){
            @Override
            protected void paintComponent(Graphics g) {
                super.paintBorder(g);
                g.drawImage(bjImg,0,0,800,600,this);
            }
        });




        //卡片布局
        this.setLayout(cardLayout);
        this.add("登录",loginPanel);//添加登陆界面
        this.add("菜单",menuPanel);//添加菜单界面
        this.add("取款",takePanel);//添加取款界面
        this.add("存款",storePanel);//添加存款界面
        this.add("查询",checkPanel);//添加查询界面



        //窗口大小
        this.setSize(800,600);
        //窗口名称
        this.setTitle("ATM取款机");
        //关闭结束程序
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        //窗口居中
        this.setLocationRelativeTo(null);
        //窗口可见
        this.setVisible(true);
    }

    public static void main(String[] args) {
        new ATM();
    }

    public void switchPanel(String name){
        cardLayout.show(this.getContentPane(),name);
    }
}
